#include <iostream>
#include <stdio.h>
#include <unistd.h>
using namespace std;
void text()
{
  pid_t id=fork();
  if(id<0)
  {
    cout<<"创建地址失败"<<endl;
  }
  else if(id==0)
  {
    int i=10;
    while(i--)
    {
      printf("%d %d %d\n",i,getpid(),getppid());
      sleep(1);
    }
  }
  else 
  {
    while(1)
    {
      printf("%d %d\n",getpid(),getppid());
      sleep(1);
    }
  }
}
void text2()
{
  int a=10;//栈区
  static int b=10;//静态区
  const char* c="abcd";//常量区 数据段

}


int init_val=10;
int uninit_val;
int main(int gev,char* argv[],char* env[])
{
  //text();
  //text2();
  
  const char* arr="abcd";
  printf("code addres:code:%p\n",main);//代码段
  printf("read only addres:%p\n",arr);//只读常量区
  printf("uninit_val addres:%p\n",&uninit_val);//未初始化区
  printf("init_val addres:%p\n",&init_val);//未初始化区


  int* nums1=new int(1);
  int* nums2=new int(1);
  int* nums3=new int(1);
  int* nums4=new int(1);
  printf("heap addres:%p\n",nums1);
  printf("heap addres:%p\n",nums2);
  printf("heap addres:%p\n",nums3);
  printf("heap addres:%p\n",nums4);
  
  int a1=10;
  int a2=10;
  int a3=10;
  int a4=10;
  printf("stack addres:%p\n",&a1);
  printf("stack addres:%p\n",&a2);
  printf("stack addres:%p\n",&a3);
  printf("stack addres:%p\n",&a4);

  printf("stack addres:%p\n",argv[0]);//命令行参数
  printf("stack addres:%p\n",env[0]);//环境变量
  return 0;
}

